import "./App.css";
import React from "react";

// React.forwardRef返回一个组件
const FancyButton = React.forwardRef((props, ref) => (
  <button ref={ref} className="FancyButton">
    {props.children}
  </button>
));
class App extends React.Component {
  constructor() {
    super();
    this.FancyButton_ref = React.createRef();
  }
  componentDidMount() {
    console.log(this.FancyButton_ref);
  }
  render() {
    return (
      <div className="App">
        <FancyButton ref={this.FancyButton_ref}>Click me!</FancyButton>
      </div>
    );
  }
}

export default App;
